import React, {Component, Fragment} from 'react';
import {getWidth, debounce} from '&helpers/tools/index'
import {connect} from 'react-redux';

class MakeEquipment extends Component {
  
  componentDidMount() {
    const {changeEquipment} = this.props;
    window.addEventListener('resize', debounce(() => {
      const w = getWidth();
      w < 768 ? changeEquipment(true) : changeEquipment(false)
    }, 100));
  }

  render(){
    return(
      <Fragment>
        {this.props.children}
      </Fragment>
    )
  }
}

const mapStateToProps = state => ({userEquipment: state.userEquipment})
const mapStateToDiapatch = dispatch => ({
  changeEquipment: dispatch.userEquipment.changeEquipment
})


export default connect(mapStateToProps, mapStateToDiapatch)(MakeEquipment)